<template>
  <div>
    <el-tooltip effect="dark" :content="text" placement="right" v-if="showTooltip()">
      <span>{{text|substr(length)}}</span>
    </el-tooltip>

    <span v-else>{{text}}</span>
  </div>

</template>

<script>
  export default {
    name: 'textAlt',
    props: {
      text: {
        type: String,
        default: ''
      },
      length: {
        type: [String, Number],
        default: 8
      }
    },
    methods: {
      showTooltip () {
        if (!this.text) {
          return false
        } else {
          return this.text.length > length
        }
      }
    }
  }
</script>

<style scoped>

</style>
